<?php

declare(strict_types=1);

namespace App\Controller;

use Hyperf\SocketIOServer\Annotation\Event;
use Hyperf\SocketIOServer\Annotation\SocketIONamespace;
use Hyperf\SocketIOServer\BaseNamespace;
use Hyperf\SocketIOServer\Socket;

/**
 * Class WebSocketController
 * @package App\Controller
 * @SocketIONamespace("/")
 */
class WebSocketController extends BaseNamespace
{
    /**
     * @Event("register")
     * @param string $data
     */
    public function onRegister(Socket $socket, $data)
    {
        $socket->join((string) $data);

        return 'registered:' . $data;
    }
}
